﻿package com.itboye.sunsun.adapter;

import java.util.ArrayList;

import com.itboye.sunsun.R;
import com.itboye.sunsun.address.AqriumModel;
import com.itboye.sunsun.address.PetModel;

import android.content.Context;
import android.graphics.Bitmap;
import android.text.Layout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

/***
 * 水族馆
 * @author l
 *
 */
public class PetAdapter extends BaseAdapter{
	ArrayList<PetModel>mList;
	Context mContext;
	int op=0;
	public  PetAdapter(ArrayList<PetModel>mList,Context mContext){
		this.mList=mList;
		this.mContext=mContext;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mList==null?0:mList.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return mList==null?0:mList.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
		
	}
	
	
	@Override
	public View getView(int arg0, View convertView, ViewGroup arg2) {
		HandView mHandView=null;
		
		if(convertView==null){
			mHandView=new HandView();
			
				convertView=LayoutInflater.from(mContext).inflate(R.layout.pet_item_list, null);
				mHandView.imghed=(ImageView) convertView.findViewById(R.id.img_post_hed);
			mHandView.name=(TextView) convertView.findViewById(R.id.post_name);
			mHandView.time=(TextView) convertView.findViewById(R.id.post_time);//textview
			mHandView.content=(TextView) convertView.findViewById(R.id.post_content);
			mHandView.leit=(ImageView) convertView.findViewById(R.id.img_post_leit);
			mHandView.centet=(ImageView) convertView.findViewById(R.id.img_post_centet);
			mHandView.right=(ImageView) convertView.findViewById(R.id.img_post_gheit);
			mHandView.ping=(ImageView) convertView.findViewById(R.id.post_item_ping);
			mHandView.zan=(ImageView) convertView.findViewById(R.id.post_item_zan);
			mHandView.zanaq=(TextView) convertView.findViewById(R.id.text_item_zan);
			mHandView.pinaq=(TextView) convertView.findViewById(R.id.text_item_pin);
			convertView.setTag(mHandView);
			
		}else {
			mHandView=(HandView) convertView.getTag();
		}
		//赋值
//		mHandView.name.setText(mList.get(arg0).getName());
		
		mHandView.imghed.setImageBitmap(mList.get(arg0).getImghed());
		mHandView.name.setText(mList.get(arg0).getName());
		mHandView.time.setText(mList.get(arg0).getTime());
		mHandView.centet.setImageBitmap(mList.get(arg0).getCentet());
		mHandView.leit.setImageBitmap(mList.get(arg0).getLeit());
		mHandView.content.setText(mList.get(arg0).getContent());
		mHandView.right.setImageBitmap(mList.get(arg0).getRight());
		mHandView.ping.setImageBitmap(mList.get(arg0).getPing());
		mHandView.zan.setImageBitmap(mList.get(arg0).getZan());
		mHandView.zanaq.setText(mList.get(arg0).getZanaq());
		mHandView.pinaq.setText(mList.get(arg0).getPinaq());
		return convertView;
	}
	class HandView{
		
		private ImageView imghed;//touxiang
		
		private ImageView leit;//做图片
		private ImageView centet;//中间
		private ImageView right;//右边
		private ImageView timeaq;//时间
		private  ImageView item_aqtime;
		private ImageView ping;//评论
		private ImageView zan;//赞
		private TextView pinaq;
		private TextView zanaq;
		private TextView time;//时间
		private TextView content;//内容
		private TextView name;
	}

}
